package com.alks.function.controller.pcFactoryQuery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.dto.pcfactoryquery.PartBfInDto;
import com.alks.function.data.request.factoryquery.PartBfInRequest;
import com.alks.function.service.pcfactoryquery.IPcSlipDetailPartBfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@ApiRestController("/pcFactorQuery")
@Api(value = "总经办", tags = "总经办-工厂查询模块-耗品入库查询")
@Slf4j
@RoleCheck(prgIds = {"100412","150209","160210","170509","170509"})
public class PartMtlInController {
    @Autowired
    private IPcSlipDetailPartBfService partBfService;

    @PutMapping("/queryPartBfIn")
    @ApiOperation(value = "耗品入库-耗品入库明细-条件可分页查询",tags = "总经办-工厂查询模块-耗品入库查询")
    @WebLogger
    public ResponseInfo queryPartBfIn(@RequestBody PartBfInRequest request){
        return ResponseInfo.ok(partBfService.queryPartBfIn(request,0));
    }

    @GetMapping("/queryPartBfInBack")
    @ApiOperation(value = "耗品入库-耗品入库-回表查询",tags = "总经办-工厂查询模块-耗品入库查询")
    @WebLogger
    public ResponseInfo queryPartBfInBack(){return partBfService.queryPartBfInBack();}

    @PostMapping("/partIn/export")
    @ApiOperation(value = "导出",tags = "总经办-工厂查询模块-耗品入库查询")
    @WebLogger
    public void partInExport(@RequestBody PartBfInRequest request, HttpServletResponse response){
        request.setPageSize(-1);
        request.setPageNum(-1);
        List<PartBfInDto> inDtoList = (List<PartBfInDto>)(partBfService.queryPartBfIn(request, 1).get("inDtos"));
        partBfService.partInExport(response,inDtoList);


    }

}
